home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: June 25, 1998
- // Author: mgr
- //
- // Description:
- // The intersectCrvPreset() procedure executes an intersect curve
- // operation on a pair of curves based on the intersect option vars.
- // In general if you have n curves selected, (n-1) curve intersect
- // operations would be carried out: each of the 1..n-1 curves is
- // intersected with the nth curve.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc intersectCrvPreset(
- int $history,
- float $tol,
- int $useDirection, // 0 - off, 1 - on, 2 - use current view direction
- // 3 - x axis, 4 - y axis, 5 - z axis
- // 6 - smart mode: use view vector in ortho view
- // but NO direction in persp view.
- float $dirX,
- float $dirY,
- float $dirZ,
- int $intersectAllCurveOrWithLast ) // 1 - intersect all curves with all curves.
- // 2 - intersect all curves with last curve only
- //
- // Description:
- // This proc takes the two selected curves and adds a marker
- // (i.e. locator) on the first curve whenever it intersects the second
- // and selects all the new markers.
- //
- {
- // Get the list of nurbs curves selected
- //
- global int $gSelectNurbsCurvesBit;
- global int $gSelectCurvesOnSurfacesBit;
- string $curveList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit -sm $gSelectCurvesOnSurfacesBit`;
- int $numSelected = size($curveList);
- if ( $numSelected < 2 )
- {
- error "Select at least two NURBS curves to intersect.";
- return;
- }
-
- // If we're to use the "current view direction", then find out what it is.
- //
- float $dir[3] ;
- $dir[0] = $dirX;
- $dir[1] = $dirY;
- $dir[2] = $dirZ;
- int $useDir = $useDirection;
- if( $useDirection == 2 ) {
- $dir = nurbsViewDirectionVector(0) ;
- $useDir = 1;
- } else if( ($useDirection == 3) ||
- ($useDirection == 4) ||
- ($useDirection == 5)) {
- // Using x axis, or y axis, or z axis. So set
- // the $useDir argument
- //
- $useDir = 1;
- } else if( ($useDirection == 6) ) {
- $dir = nurbsViewDirectionVector(0) ;
- $useDir = 2;
- }
- if( $useDir == 2 ) {
- // If persp view, then $useDir = 0;
- // If ortho view, then $useDir = 1;
- string $currentCamera = `lookThru -q`;
- if( `camera -q -o $currentCamera` ) {
- $useDir = 1;
- } else {
- $useDir = 0;
- }
- }
-
- // Find all intersections with ALL CURVES or with LAST CURVE only
- //
- string $resultLocators[];
- string $parms[];
- string $intersectNodes[];
- if( $intersectAllCurveOrWithLast == 1 ) {
- $parms = findAllIntersections( $curveList,
- $numSelected, // this means all curves
- $useDir, $dir[0], $dir[1], $dir[2], $tol, 0, // 0 means unsorted
- $history, $intersectNodes );
- } else {
- $parms = findAllIntersections( $curveList,
- 1, // 1 means last curve
- $useDir, $dir[0], $dir[1], $dir[2], $tol, 0, // 0 means unsorted
- $history, $intersectNodes );
- }
-
- // For each intersection, create a locator
- //
- int $c, $p;
- int $numParms;
- for( $c = 0; $c < $numSelected; $c ++ ) {
-
- // Parse the parms string into a list of parameter values
- string $tok[];
- float $floatParms[];
- int $numTok = `tokenize $parms[$c] " " $tok`;
- if( $numTok == 0 ) continue;
- for( $j = 0; $j < $numTok; $j ++ ) {
- if( size($tok[$j]) > 0 ) {
- $floatParms[$j] = $tok[$j];
- }
- }
- $numParms = size($floatParms);
- if( $numParms == 0 ) continue;
-
- // Parse out the intersect node string, if there is one
- //
- string $nodes[];
- int $numNodes = `tokenize $intersectNodes[$c] " " $nodes`;
-
- // For each parameter value in $floatParms, create a locator and
- // add it to the resultLocators list
- //
- for( $p = 0; $p < $numParms; $p ++ ) {
- $locator = eval("paramLocator " + $curveList[$c] + ".u["
- + $floatParms[$p] + "]");
- $resultLocators[size($resultLocators)] = $locator;
-
- // if history is on then connect the crv/crv intersect node
- // parameter value to a locator
- //
- if( ($history == 1) && ($numNodes > 0)) {
- connectAttr $nodes[$p] ($locator + ".localPositionX");
- }
- }
- clear($floatParms);
- }
-
- // Select all the new markers
- //
- if ( size($resultLocators) > 0 ) select -r $resultLocators;
- }
-